<%--
  Created by IntelliJ IDEA.
  User: c66
  Date: 2017/7/27
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <title>编辑日志</title>
    <script type="text/javascript" src="../../static/common/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="../../static/common/jquery/jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" href="../../static/common/layui/css/layui.css">
</head>
<body>
<div style="margin: 15px;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label layui-form-newlabel_ren">编辑日志</label>
            <div style="    margin-left: 110px;">
                <textarea id="ta_ckeditor" class="ckeditor my-math" cols="20" rows="2" style="overflow:auto; height:800px"></textarea>
                <script >CKEDITOR.replace('ta_ckeditor');</script>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="edit">上传日志</button>
            <input type="button" class="layui-btn"  lay-submit="" lay-filter="return" value="返回">
        </div>
    </div>
</div>
<script src="../../static/common/layui/layui.js"></script>
<script>
var  content = "<%=request.getParameter("test").toString()%>";
var  id = "<%=request.getParameter("test1").toString()%>";
console.log(content);
console.log(id);
var divshow = $("#ta_ckeditor");
divshow.text("");// 清空数据
divshow.html(content);
</script>
<script>
    layui.use(['form','jquery','layer'],function() {
        var form = layui.form(),
            $ = layui.jquery;

        form.on('submit(edit)', function (data) {
            data.field.content= CKEDITOR.instances.ta_ckeditor.getData();
            data.field.id= id;
            console.log(data.field);
            $.ajax({
                url:'/internlog/modify'
                ,type:'post'
                ,contentType : "application/json; charset=utf-8"
                ,data:JSON.stringify(data.field)
                ,dataType:'json'
                ,success:function (response) {
                    layer.msg(response.message,{time: 1500},function () {
                        location.reload();
                        location.href='/student/practiceDiary1';
                    });
                }
            });
            return false;
        });
        form.on('submit(return)',function () {
            location.reload();
            location.href='/student/practiceDiary1';
        });
    })
</script>

</body>
</html>
